<?php
// $Id: nodeprofile_workflow_ng.inc,v 1.1.2.2 2007/09/15 11:49:21 fago Exp $

/**
 * @file
 * Some workflow-ng conditions/actions
 */

/*
 * Implementation of hook_condition_info()
 */
function nodeprofile_condition_info() {
  return array(
    'nodeprofile_user_has_profile_condition' => array(
      '#label' => t('User has nodeprofile'),
      '#arguments' => array(
        'node' => array('#entity' => 'user', '#label' => t('User')),
      ),
      '#module' => t('Node Profile'),
    ),
  );
}

/*
 * Implementation of a worklfow-ng action: enables revision moderation
 */
function nodeprofile_user_has_profile_condition($user, $settings) {
  $node = nodeprofile_load($settings['type'], $user->uid);
  return (bool)$node;
}

/*
 * Implementation of a worklfow-ng action: disables revision moderation
 */
function nodeprofile_user_has_profile_condition_form($settings) {
  $form['type'] = array(
    '#type' => 'select',
    '#title' => t('Node Profile Content Type'),
    '#options' => nodeprofile_get_types('names'),
    '#default_value' => isset($settings['type']) ? $settings['type'] : array(),
    '#description' => t('Select the node profile content type, which the user must have created.'),
    '#required' => TRUE,
  );
  return $form;
}

function nodeprofile_user_has_profile_condition_submit($form_id, $form_values) {
  return array('type' => $form_values['type']);
}

